stack = []

brackets = {
    '[' : ']',
    '(' : ')',
    '<': '>',
    '{': '}',
}

def get_closed_bracket(c):
    if c in brackets:
        return brackets[c]
    else:
        return ""

def check_brackets (s):
    for c in s:
        if c in brackets:
            push(c)
        else:
            d = pop()
            if d is None:
                return False
            if get_closed_bracket(d) == c:
                continue
            else:
                return False
    if is_empty():
        return True
    else:
        return False

def pop():
    if is_empty():
        return None
    else:
        element = stack.pop()
        return element

def push(n):
    stack.append(n)

def peek():
    if is_empty():
        return None
    else:
        return stack[-1]

def is_empty():
    return len(stack) == 0


s =input()
print ('YES' if check_brackets(s) else 'NO')
